<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2020/5/22
 * Time: 16:06
 */
namespace app\admin\controller;
use think\Db;
use think\Request;
class Other extends Base {
    /**
     * 用户协议
     * @return mixed|\think\response\Json
     */
    public function userAgreement(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id', 1)
                ->update(['other_user_agreement' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 1)->value('other_user_agreement');
        $this->assign('agreement', $agreement);
        return $this->fetch('other/useragreement');
    }
    /**
     * 隐私协议
     * @return mixed|\think\response\Json
     */
    public function ysAgreement(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id', 2)
                ->update(['other_ys_agreement' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 2)->value('other_ys_agreement');
        $this->assign('agreement', $agreement);
        return $this->fetch('other/ysagreement');
    }
    /**
     * 用户协议
     * @return mixed|\think\response\Json
     */
    public function aboutus(){
        if(Request::instance()->isPost()){
            $agreement = input('agreement');
            $res = Db::table('up_other')
                ->where('other_id', 3)
                ->update(['other_aboutus' => $agreement]);
            if($res){
                return json(['code' => 200, 'msg' => '保存成功']);
            }else{
                return json(['code' => 100, 'msg' => '保存失败']);
            }
        }
        $agreement = Db::table('up_other')->where('other_id', 3)->value('other_aboutus');
        $this->assign('agreement', $agreement);
        return $this->fetch('other/aboutus');
    }
}